package com.ynny.controller;

import com.ynny.entity.R;
import com.ynny.entity.User;
import com.ynny.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/user")
public class UserController {
    @Autowired
    UserService UserService;

    @PostMapping("/register")
    public R register(@RequestBody User user){
        if (user.getNumber().equals("") || user.getPassword().equals("") ||user.getId().equals("")){
            System.out.println("用户名密码不能为空");
        }
        int res = UserService.resigister(user);

        if (res == 205){
            System.out.println("用户名重复");

        }
        user.setPassword(null);
        return R.ok(user);


    }
}